﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NEM.Genaral_WinOS_Functions
{
    class Windows_Information
    {
        #region Private Variables / Constants

        #endregion


        #region Constructors
        public Windows_Information()
        {

        }
        #endregion

        #region Properties

        #endregion

        #region Methods
        public OSVersion WindowsVersion()
        {
            OSVersion lvResult = OSVersion.Unknown;

            System.OperatingSystem lvOS = Environment.OSVersion;
            Version lvVersionNumber = lvOS.Version;

            if (lvOS.Platform == PlatformID.Win32Windows)
            {
                switch (lvVersionNumber.Minor)
                {
                    case 0:
                        lvResult = OSVersion.Windows_95;
                        break;

                    case 10:
                        lvResult = OSVersion.Windows_98;
                        break;

                    case 90:
                        lvResult = OSVersion.Windows_ME;
                        break;

                    default:
                        break;
                }
            }

            else if (lvOS.Platform == PlatformID.Win32NT)
            {
                switch (lvVersionNumber.Major)
                {
                    case 3:
                        lvResult = OSVersion.Windows_NT;
                        break;
                    case 4:
                        lvResult = OSVersion.Windows_NT;
                        break;
                    case 5:
                        if (lvVersionNumber.Minor == 0)
                            lvResult =  OSVersion.Windows_2000;
                        else
                            lvResult = OSVersion.Windows_XP;
                        break;
                    case 6:
                            {
                                switch (lvVersionNumber.Minor)
	                            {
                                    case 0 :    lvResult = OSVersion.Windows_Vista; 
                                                break;

                                    case 1 :    lvResult = OSVersion.Windows_8;
                                                break;

                                    case 2 :    lvResult = OSVersion.Windows_8_1;
                                                break;

		                            default:
                                                break;
	                            }
                            }
                            break;


                    default:
                        break;
                }
            }
            MessageBox.Show("operating System: " + lvResult.ToString() +
                            "\nOS Version: " + lvOS.Version.ToString() +
                            "\nOS Platoform: " + lvOS.Platform.ToString() +
                            "\nOS SP: " + lvOS.ServicePack.ToString() +
                            "\nOS Version String: " + lvOS.VersionString.ToString());
            
            
            return lvResult;
        }
        #endregion

        #region Overrides
        public override string ToString()
        {
            return "";
        }
        #endregion
    }
    public enum OSVersion
    {
        Unknown,
        Windows_NT,
        Windows_95,
        Windows_98,
        Windows_ME,
        Windows_2000,
        Windows_XP,
        Windows_XP_64_Bit_Edition,
        Windows_Vista,
        Windows_Server_2003,
        Windows_Server_2003_R2,
        Windows_Server_2008,
        Windows_Server_2008_R2,
        Windows_7,
        Windows_Server_2012,
        Windows_8,
        Windows_Server_2012_R2,
        Windows_8_1

    }

}
